package com.itheima.原子性;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author 王加鑫
 * @Date 2021/5/23 14:52
 * @Version 1.0
 */
public class MyAtomrThread implements Runnable {

    AtomicInteger ato = new AtomicInteger(0);


    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            ato.getAndIncrement();
            System.out.println("买了" + ato.get() + "支玫瑰花");
        }
    }
}
